import type { LoginUser, Token } from "@/service/type";
import { defineStore } from 'pinia';


export const tokenStore = defineStore('token', {
  state: () => ({
    token: null as string | null
  }),
  getters: {
    getToken: (state) => state.token
  },
  actions: {
    setToken(token: string | null) {
      this.token = token;
      if (token) {
        uni.setStorageSync('token', token);
      } else {
        // 当 token 为 null 时，确保从存储中移除
        uni.removeStorageSync('token');
      }
    }
  }
});